[ToC] [Up] [Back] [Next] ... [Book Plug] The Information Commons
.................... Introduction to HTML

4.12.2 NAME attribute in an Anchor

As mentioned in the anchors overview section, anchors mark the beginning or end of hypertext links. The NAME attribute (which is optional) marks the anchor as a possible destination of a link from another document, or from somewhere else within the same document.

The value assigned to a NAME should be a name token.

NOTE:
HTML 3 suggested renaming the NAME attribute to ID. Don't do this yet -- there are no current browsers that recognize the ID attribute.

Usage of NAME

Here is a typical example:
<A NAME="poison"> Toadstools </A>
Where the identifier poison is used to NAME the anchored text as the possible target of a hypertext link. The reference identifier can be an arbitrary string, but it must be unique within the document.

Targeting NAMEd Anchors

Named anchors can be targeted, from within the same document, using HREF - you simply HREF the name, prepending a `#':
<A HREF="#poison"> Poisonous non-mushrooms </A>

you can also target the NAMEd anchor from another document, simply by adding the NAME after the document URL. For example, if the identifier `poison' was located in the file `toads.html' it could be referenced by either

<A HREF="toads.html#poison"> Poisonous non-mushrooms </A>
or
<A HREF="http://www.site.edu/slimy/toads.html#poison"> Poisonous 
non-mushrooms </A>.

Active Example Of NAME

Here, for example, is a link back to the top of this page. The coding is <a href="#top">top of this page</a>.


[ToC] [Up] [Back] [Next] ... [Book Plug] .................... Introduction to HTML

© Ian Graham 1994-1995 Page Last Updated: 4 December 1995